<%-- 
    Document   : getfuns
    Created on : 11/Abr/2010, 1:05:38
    Author     : luis
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"
    import="pt.our.angemc.parser.*"
    import="pt.our.angemc.datatypes.*"
    import="org.json.*"
    import="java.util.HashMap"
    import="org.apache.commons.codec.binary.Base64"
    import="java.io.FileOutputStream"
    import="java.io.*"
%>

<%
    JSONObject obj = new JSONObject();

    String text = request.getParameter("text");
    Parser2 p = new Parser2();

    if(p.checkGrammar(text).equals("0"))
    {
        
        Base64 b = new Base64();
        String img = b.encodeToString(p.grafo(text));
        obj.put("success", true);
        obj.put("img", img);   
    }
    else
    {
        obj.put("success", false);
    }
    
    out.print(obj);
%>